// pages/invitation/invitation.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    codeImg: null
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const userId = app.globalData.userId;
    wx.request({
      url: app.baseURL + 'Distribution&a=get_qrcode',
      data: {
        user_id: userId,
        path: '/pages/index/index?other_user_id=' + userId + '&type=1'
      },
      success: res => {
        this.setData({
          codeImg: "https://jrtest.0791jr.com/data/attachment/qrcode/" + res.data.qrcode
        });
      }
    })
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function (res) {
    if (res.from === 'button') {
      // 来自页面内转发按钮
      // console.log(res.target)
    }
    return {
      title: '邀请好友成为分销商',
      path: '/pages/index/index?other_user_id=' + app.globalData.userId + '&type=1'
    }
  },
  /**
  * 用户点击右上角分享
  */
  share: function (res) {
    if (res.from === 'bindtap') {
      // 来自页面内转发按钮
      // console.log(res.target)
    }
    return {
      title: '邀请好友得佣金',
      path: '/pages/index/index?other_user_id=' + app.globalData.userId + '&type=1'
    }
  },
  //禁止滑动
  preventSlide() { },
})